package cn.lix.sc.mongo;

import cn.lix.sc.mongo.dao.UserDAO;
import cn.lix.sc.mongo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;
import java.util.List;

@SpringBootApplication
public class MongoApplication {

    @Autowired
    private UserDAO dao;

    public static void main(String[] args) {
        SpringApplication.run(MongoApplication.class, args);
    }

    @PostConstruct
    public void init() {
        /*User user = new User();
        user.setId(1);
        user.setName("zhangsan");
        user.setAge(23);
        user.setAddr("四川省成都市邛崃市xxx");
        user.setPhoneNo(18080955441L);
        mongoTemplate.insert(user);*/

        long start = System.currentTimeMillis();
//        List<User> users = dao.findAllByAgeBetween(67, 69);
        List<User> users = dao.findUserByPhoneNoLessThan(18080955491L);
        System.out.println("查询完毕耗时：" + (System.currentTimeMillis() - start));
        System.out.println(users);
    }

}
